let _ = require('lodash');

class aim {
  constructor(opt) {
    let def = {
      innerRadius: 0, //内径
      outerRadius: 100, //外径
      color: 'red',
    };
    let opts = Object.assign({}, def, opt);
    this.innerRadius = opts.innerRadius;
    this.outerRadius = opts.outerRadius;
    this.color = opts.color;
  }

  draw(ctx, info) {
    let ctxW = ctx.canvas.width;
    let ctxH = ctx.canvas.height;
    let centerX = ctxW / 2;
    let centerY = ctxH / 2;
    // ctx.moveTo(centerX, centerY);
    // 设置颜色
    ctx.strokeStyle = this.color;
    ctx.lineWidth = 3; // 可根据需要调整线宽

    ctx.beginPath();
    ctx.moveTo(centerX - this.innerRadius, centerY);
    ctx.lineTo(centerX - this.outerRadius, centerY);
    ctx.stroke();

    ctx.beginPath();
    ctx.moveTo(centerX + this.innerRadius, centerY);
    ctx.lineTo(centerX + this.outerRadius, centerY);
    ctx.stroke();

    ctx.beginPath();
    ctx.moveTo(centerX, centerY - this.innerRadius);
    ctx.lineTo(centerX, centerY - this.outerRadius);
    ctx.stroke();

    ctx.beginPath();
    ctx.moveTo(centerX, centerY + this.innerRadius);
    ctx.lineTo(centerX, centerY + this.outerRadius);
    ctx.stroke();

    ctx.beginPath();
    ctx.arc(centerX, centerY, 1, 0, 2 * Math.PI);
    ctx.stroke();
  }
}

export { aim };
